//
// Created by liuping on 2019/3/27.
//

#include "define.h"
#include "test_base.h"

TEST_F(scope) {
    int i = 0;
    SCOPE {
        i++;
        ASSERT_EQ(i, 1);
        if (i == 1) {
            break;
        }
        // 运行不到这里来
        ASSERT_EQ(i, 0);
    };

    i = 0;

    SCOPE_IF(i == 0) {
        INFO << "if i=" << i;
        break;
        INFO << "never appear";
    }
    SCOPE_ELSE_IF(i == 1) {
        INFO << "else if i=" << i;
        break;
        INFO << "never appear";
    }
    SCOPE_ELSE {
        INFO << "else i=" << i;
        break;
        INFO << "never appear";
    };

    i = 1;
    SCOPE_IF(i == 0) {
        INFO << "if i=" << i;
        break;
        INFO << "never appear";
    }
    SCOPE_ELSE_IF(i == 1) {
        INFO << "else if i=" << i;
        break;
        INFO << "never appear";
    }
    SCOPE_ELSE {
        INFO << "else i=" << i;
        break;
        INFO << "never appear";
    };

    i = 2;
    SCOPE_IF(i == 0) {
        INFO << "if i=" << i;
        break;
        INFO << "never appear";
        }
    SCOPE_ELSE_IF(i == 1) {
        INFO << "else if i=" << i;
        break;
        INFO << "never appear";
    }
    SCOPE_ELSE {
        INFO << "else i=" << i;
        break;
        INFO << "never appear";
    };
}

TEST_FINSH